/*Author:no-bald-chen
 * Time:2021/8/26
 * */
package Algorithm.sort;

import Utils.Swap;

//快速排序,非严格递增
public class Quick_sort {
    private int[] nums;

    public Quick_sort(int[] nums){
        this.nums = nums;
    }

    public void Sort(int left,int right){
        int i = left,j =right;
        if (i>=j){
            return;
        }
        int target = nums[i];
        while (i<j){
            while (nums[j]>target && i<j){
                j--;
            }
            while (nums[i]<=target && i<j){
                i++;
            }
            if (i<j){
                Swap.swap(nums,i,j);
            }
        }
        Swap.swap(nums,left,i);
        Sort(left,i-1);
        Sort(i+1,right);
    }

}
